Ext.define('AmpleHarvest.objects.search.results.panel.cSavedQuery',
{
	extend				: 'Ext.form.Panel',
	title				: "Saved Queries",
	stateId				: "Saved_Query_Window",
	collapsible			: true,
	// resizable : true,
	layout				: 'anchor',
	width				: 350,
	// collapseFirst : false,
	// collapseDirection : "right",
	frame				: true,
	m_str_SourceGUID	: "",
	requires			:
	[
			"AmpleHarvest.objects.search.results.grid.cSavedQuery",

			"Ext.button.Button"
	],

	initComponent		: function()
	{
		var obj_This = this;
		
		this.m_obj_Grid = Ext.create("AmpleHarvest.objects.search.results.grid.cSavedQuery",
				{
					m_str_SourceGUID	: this.m_str_SourceGUID,
					anchor				: "100% 100%"
				});

		this.tbar =
		[
			Ext.create("Ext.button.Button",
			{
				text	: "Manage Saved Queries",
				handler	: function()
				{
					location.href = obj_config.C_STR_QUERY_MANAGER_PATH;
				}
			}
			)
		];
		this.items =
		[
			this.m_obj_Grid
		]
		this.tools =
		[
				{
					type	: 'refresh',
					handler	: function()
					{
//						m_obj_SearchWin
						this.up('ampleharvest-objects-search-panel-csearch').fireEvent(AmpleHarvest.eventHandler.cWindowEvents.C_STR_EVENT_SAVED_QUERY_CHANGED);
					}
				}
		],

		this.callParent();

		this.on("beforestaterestore", function(obj_This, obj_State, obj_Opts)
				{
					m_obj_AmpleHarvest_ViewPort.g_obj_RestStateProvider.add_StateObject(this.stateId, this);
				}, this
		);

	},

	load_Query			: function(str_Data)
	{
		this.ownerCt.load_Query(str_Data);
		this.ownerCt.do_Search();
	}

}
);